#ifndef PLCHELPER_H
#define PLCHELPER_H

#include "base/errorcode.h"
#include "src/pubimp.h"
#include "../modbusControl/mbControl.h"
#include "tools.h"
#include <future>
#include "src/define/func_define.h"
#include "base/instancecall.h"


class PLCHelper
{
public:
    PLCHelper();

    static PLCHelper* GetInstance(){
        static QMutex mutex;
        static QScopedPointer<PLCHelper> inst;
        if (Q_UNLIKELY(!inst)) {
            mutex.lock();
            if (!inst) {
                inst.reset(new PLCHelper);
            }
            mutex.unlock();
        }
        return inst.data();
    }

    MU_RETURNS OpenAirValve();  // 打开汽阀，使枪头伸出
    MU_RETURNS CloseAirValve();  // 关闭汽阀，使枪头收回
    void Connect();

private:
    std::shared_ptr<mbControl> _mb_ptr;///电机指针
    MU_RETURNS _connect();
    InstanceCall _ins;
};

#endif // PLCHELPER_H
